package com.android.plano;

import com.android.alarme.Controller;
import com.android.main.TelaPrincipal;
import com.android.main.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class NovoPlano extends Activity {
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tela_novo_plano);
        
        final Toast msg = Toast.makeText(this, "Preencha todos os valores", 2);
        
        final Intent it = new Intent(this, TelaPrincipal.class);
        final Intent newit = new Intent(this, NovoHorario.class);
        
        Button btnVoltar = (Button) findViewById(R.button.btnvoltar);
        btnVoltar.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
			
				startActivity(it);
				onDestroy();
			}
		});
        
        final Activity contx = this;
        Button btnAvancar = (Button) findViewById(R.button.btnconcluir);
        btnAvancar.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				String[] val = new String[2];
				
				EditText edtNome = (EditText) findViewById(R.edttext.edtextnome);
				EditText edtAgua = (EditText) findViewById(R.edttext.edtextagua);
			
				if(edtAgua.getText().toString().equalsIgnoreCase("") || edtNome.getText().toString().equalsIgnoreCase("")){
					//msg.show();
				}else{
					
					String nome = edtNome.getText().toString();
					int qtdLitros = Integer.parseInt(edtAgua.getText().toString());
					float porcoes = 2;
					
					Controller.getInstance().setPorcoes(porcoes, contx);
					Controller.getInstance().setLitros(qtdLitros, contx);
					Controller.getInstance().setUsuario(nome, contx);
					
					startActivity(newit);
					finish();
				}
				
			}
		});
    }
}
